package org.halo.trade.data.sina;


public class Level
{
	public String symbol;// 证券代码
	public String name;

	public double lastclose;
	public double open;
	public double high;
	public double low;

	public double price;// 最新 价格
	public double tradecount;// 成交笔数
	public double amount;// 成交额
	public double volume;// 成交量
	public long time;// 时间
	public int op;// // 方向

	// 买一价 买二价 买三价 买四价 买五价 卖一价 卖二价 卖三价 卖四价 卖五价
	// 买一量 买二量 买三量 买四量 买五量 卖一量 卖二量 卖三量 卖四量 卖五量

	public long askvol1;
	public long askvol2;
	public long askvol3;
	public long askvol4;
	public long askvol5;

	public double ask1;
	public double ask2;
	public double ask3;
	public double ask4;
	public double ask5;

	public long bidvol1;
	public long bidvol2;
	public long bidvol3;
	public long bidvol4;
	public long bidvol5;

	public double bid1;
	public double bid2;
	public double bid3;
	public double bid4;
	public double bid5;

	static public final int OP_BUY = 0;
	static public final int OP_SELL = 1;

	double getSpread()
	{
		return (ask1 - bid1);
	}

	double getSpreadRate()
	{
		if (bid1 > 0)
		{
			return (ask1 - bid1) / bid1;
		}
		return Double.MAX_VALUE;
	}
	
	public void printSpreadInfo()
	{
		System.out.println(symbol+" " + name + " spread:"+Utils.doubleToString(getSpread(), 3)+" spreadRate:"+Utils.doubleToString(getSpreadRate()*100, 3)+"%");
	}
	
	public void print()
	{
		System.out.println(Utils.msToStr(time));
		System.out.println(name + " " + symbol);
		System.out.println("开盘:" + open + " 昨收:" + lastclose);
		System.out.println("最低:" + low + " 最高:" + high);
		System.out.println("最新:" + price + " 量：" + volume + " 成交额:" + amount);
		System.out.println("spread:"+Utils.doubleToString(getSpread(), 3)+" spreadRate:"+Utils.doubleToString(getSpreadRate()*100, 3)+"%");

		System.out.println("---------------------------");
		System.out.println("卖五 \t" + ask5 + " \t" + askvol5);
		System.out.println("卖四 \t" + ask4 + " \t" + askvol4);
		System.out.println("卖三 \t" + ask3 + " \t" + askvol3);
		System.out.println("卖二 \t" + ask2 + " \t" + askvol2);
		System.out.println("卖一 \t" + ask1 + " \t" + askvol1);
		System.out.println("---------------------------");

		System.out.println("买一 \t" + bid1 + " \t" + bidvol1);
		System.out.println("买二 \t" + bid2 + " \t" + bidvol2);
		System.out.println("买三 \t" + bid3 + " \t" + bidvol3);
		System.out.println("买四 \t" + bid4 + " \t" + bidvol4);
		System.out.println("买五 \t" + bid5 + " \t" + bidvol5);
	}
}
